fs/iso9660: Fix invalid free
authorMichael Chang <mchang@suse.com>
Fri, 31 May 2024 07:14:42 +0000 (15:14 +0800)
committerMiao Wang <shankerwangmiao@gmail.com>
Sun, 15 Feb 2026 13:50:20 +0000 (13:50 +0000)
commita633e817aefeb9affef946c2e7e40a066a962e9f
tree9a58c022745b6cbf22eb9931400e5e7c29f31f30
parent5915107401ba26b1e4c0a48fd635b06781cea7e2
fs/iso9660: Fix invalid free

The ctx->filename can point to either a string literal or a dynamically
allocated string. The ctx->filename_alloc field is used to indicate the
type of allocation.

An issue has been identified where ctx->filename is reassigned to
a string literal in susp_iterate_dir() but ctx->filename_alloc is not
correctly handled. This oversight causes a memory leak and an invalid
free operation later.

The fix involves checking ctx->filename_alloc, freeing the allocated
string if necessary and clearing ctx->filename_alloc for string literals.

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name fs-iso9660-Fix-invalid-free.patch
grub-core/fs/iso9660.c